package com.changhai.diabetes.action;

import java.util.List;

import com.changhai.diabetes.model.Concurrent;
import com.changhai.diabetes.model.ConcurrentResult;
import com.changhai.diabetes.model.OpertResultMsg;
import com.changhai.diabetes.service.ConcurrentService;

/**
 * 并发及伴随症
 * 
 * @author Andy
 * 
 */
public class ConcurrentAction extends BaseAction {

	private static final long serialVersionUID = 4392936553263004630L;
	private OpertResultMsg opertMsg;
	private Long patientid;
	private List<Concurrent> concurrents;
	private ConcurrentResult contResult;
	private ConcurrentService concuService;
	private String concurrentids;
	private String diagtimes;
	private String xuezhitype;
	private Integer flag = 0;

	public String execute() throws Exception {
		return super.execute();
	}

	public String query() {
		return "input";
	}

	public String editConcurrent() {
		if (patientid != null && patientid > 0) {
			try {
				concurrents = concuService.searchAllCons();
				contResult = concuService.searchReByPatientId(patientid);
				tbList = this.getTableForEnter(patientid, flag);
			} catch (Exception e) {
				e.printStackTrace();
				opertMsg = new OpertResultMsg(Long.valueOf(1), "暂无并发症信息!");
			}
			return "input";
		} else {
			return "query";
		}
	}

	public String saveEditConcurrent() {
		if (patientid == null || patientid <= 0 || contResult == null) {
			opertMsg = new OpertResultMsg(Long.valueOf(1), "参数错误!");
		} else {
			try {
				contResult.setConcurrentids(concurrentids);
				contResult.setDiagtimes(diagtimes);
				contResult.setXuezhitype(xuezhitype);
				concuService.saveEditConcurrent(contResult);
				opertMsg = new OpertResultMsg(Long.valueOf(0), "保存成功!");
				commonService.writeLogToFile("update", "并发", patientid);
			} catch (Exception e) {
				opertMsg = new OpertResultMsg(Long.valueOf(1), "保存失败!");
			}
		}
		return this.editConcurrent();
	}

	public OpertResultMsg getOpertMsg() {
		return opertMsg;
	}

	public void setOpertMsg(OpertResultMsg opertMsg) {
		this.opertMsg = opertMsg;
	}

	public Long getPatientid() {
		return patientid;
	}

	public void setPatientid(Long patientid) {
		this.patientid = patientid;
	}

	public ConcurrentService getConcuService() {
		return concuService;
	}

	public void setConcuService(ConcurrentService concuService) {
		this.concuService = concuService;
	}

	public List<Concurrent> getConcurrents() {
		return concurrents;
	}

	public void setConcurrents(List<Concurrent> concurrents) {
		this.concurrents = concurrents;
	}

	public ConcurrentResult getContResult() {
		return contResult;
	}

	public void setContResult(ConcurrentResult contResult) {
		this.contResult = contResult;
	}

	public String getConcurrentids() {
		return concurrentids;
	}

	public void setConcurrentids(String concurrentids) {
		this.concurrentids = concurrentids;
	}

	public String getDiagtimes() {
		return diagtimes;
	}

	public void setDiagtimes(String diagtimes) {
		this.diagtimes = diagtimes;
	}

	public String getXuezhitype() {
		return xuezhitype;
	}

	public void setXuezhitype(String xuezhitype) {
		this.xuezhitype = xuezhitype;
	}

	public Integer getFlag() {
		return flag;
	}

	public void setFlag(Integer flag) {
		this.flag = flag;
	}
}
